home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / FH-3DTUT.ZIP / TUT1.PAS < prev    next >
Pascal/Delphi Source File  |  1995-12-23  |  1KB  |  48 lines

  1. program Tutorial1;
  2. {Point Rotation
  3.  Made by fh94.3 (C) 12/23/1995
  4.  Mail: fh@viktoria.drp.fmph.uniba.sk
  5.  
  6.  Based on explanation by Synergist (rtr0982@grace.rit.edu)
  7. }
  8. uses tutunit,crt;
  9.  
  10. var x,y,z,xt,yt,zt:real; {virtual points, temp points}
  11.     xan,yan,zan:real; {angles for X,Y,Z axis}
  12.     sx,sy: integer; {screen coords}
  13.  
  14. begin
  15. Mcgaon;      {sets to 13h (320x200x256) mode}
  16. Zan :=  0.3; {angle for rotation about Z axis}
  17. Yan :=  0.1; {angle for rotation about Y axis}
  18. Xan :=  0.1; {angle for rotation about X axis}
  19.  
  20. x:=10;  {coord of point on X axis}
  21. y:=20;  {coord of point on Y axis}
  22. z:=20;  {coord of point on Z axis}
  23.  
  24. repeat
  25. SETPIXEL(SX,SY,0);
  26. Yt:= Y * COS(Xan) - Z * SIN(Xan); {calculates position after rotating}
  27. Zt:= Y * SIN(Xan) + Z * COS(Xan); {about the X axis}
  28. Y:= Yt;
  29. Z:= Zt;
  30. Xt:= X * COS(Yan) - Z * SIN(Xan); { '  ' about Y axis}
  31. Zt:= X * SIN(Yan) + Z * COS(Xan);
  32. X:= Xt;
  33. Z:= Zt;
  34. Xt:= X * COS(Zan) - Y * SIN(Zan); { '  ' about Z axis}
  35. Yt:= X * SIN(Zan) + Y * COS(Zan);
  36. X:= Xt;
  37. Y:= Yt;
  38. sx:=round(x)+160; {converts REAL to INTEGER,}
  39. sy:=round(y)+100; {160,100 is the centre of the screen}
  40.  
  41. SETPIXEL(SX,SY,15); {draws the point}
  42. delay(30); {just a delay}
  43.  
  44. until keypressed; {loops until you press a key}
  45.  
  46. MCGAOff; {Back to text (old) mode}
  47. end.
  48.